define(function(require,exports,module){
	
	
	//判断版本 0 为标准版
	/*var depositVal =$("#deposit").val();*/
	
	$("#amountApply").click(function(){
		//判断是否已认证或开通第三方接口
		$.ajax({
			url:"/member/useridentify/realNameStatus.html?randomTime=" + (new Date()).getTime(),
			type:"get",
			dataType:"json",
			success:function(data){
				if(data.result==false){
						/*if(depositVal==0){*/
							window.layer.open({
								type: 1,
								closeBtn: 0,
				                title: "&nbsp;",
							    area: ['450px', '190px'],
							    border: [1, 1, '#cecfd0'],
							    content: '<div class="tipsWrap w450"><div class="tipsTxt"><i class="iconfont tipIco">&#xe63c;</i><span>您尚未通过实名认证，请先认证。</span></div><div class="tipsBtnBar"><a href="/member/security/setting.html" class="okBtn">马上去认证</a></div></div>'
							});
						/*}else{
							window.layer.open({
								type: 1,
								closeBtn: 0,
				                title: "&nbsp;",
							    area: ['450px', '190px'],
							    border: [1, 1, '#cecfd0'],
							    content: '<div class="tipsWrap w450"><div class="tipsTxt"><i class="iconfont tipIco">&#xe63c;</i><span>您尚未通过实名认证，请先认证。</span></div><div class="tipsBtnBar"><a href="/member_borrow/security/realNameIdentify.html" class="okBtn">马上去认证</a></div></div>'
							});
						}*/
				}
				
			}
		})
	});

	
	
	//申请额度验证
		$("#addAmountApply").validate({
			rules:{
				amount:{
					required:true,
					min:1,
					max:10000
				},
				content:{
					required:true
				}
			},
			messages:{
				amount:{
					required:"请填写申请金额",
					min:"申请金额最小为1元",
					max:"申请金额不能超过10000元"
				},
				content:{
					required:"请写上详细信息"
				}
			},
			errorPlacement:function(error, element){
			  	element.parents(".ipt").find("em").html(error);	
			},
			success:function(element){
				element.parents(".ipt").find("em").html("");
			},
		    success:function(label){
		    },
		    submitHandler:function(form,event,validator){
				 $(form).ajaxSubmit({
   					dataType:'json',
   					success:function(data){
						if(data.result){
							var closeLayer = window.layer.open({
								type: 1,
							    closeBtn: 1,
				                title: "&nbsp;",
							    area: ['384px', '186px'],
							    border: [1, 1, '#cecfd0'],
							    content: '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont okIco">&#xe63d;</i><span>申请提交成功，请耐心等待审核！</span></div><div class="tipsBtnBar"><a href="javascript:;" class="okBtn failBtn">确定</a></div></div>',
							    cancel: function(index){
							    	window.location.href="/member_borrow/borrow/creditApply.html";
							    }
							});
							$(".failBtn").click(function(){
								window.location.href="/member_borrow/borrow/creditApply.html";
							});
    					}else{
    						window.layer.open({
								type: 1,
							    closeBtn: 1,
				                title: "&nbsp;",
							    area: ['384px', '186px'],
							    border: [1, 1, '#cecfd0'],
							    content: '<div class="tipsWrap w384"><div class="tipsTxt"><i class="iconfont errIco">&#xe63e;</i><span>'+data.msg+'</span></div><div class="tipsBtnBar"><a href="javascript:;" class="okBtn failBtn">确定</a></div></div>',
							    cancel: function(index){
							    	layer.closeAll();
							    	$("#addAmountApply")[0].reset();
							    }
							});
							$(".failBtn").click(function(){
								layer.closeAll();
								$("#addAmountApply")[0].reset();
							});
    					}
   					}
   				});				
			}
		    
		    
		});

});